home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 276_01 / a16.h < prev    next >
C/C++ Source or Header  |  1989-10-01  |  11KB  |  378 lines

  1. /*
  2.     HEADER:        CUG276;
  3.     TITLE:        PIC1650 Cross-Assembler (Portable);
  4.     FILENAME:    A16.H;
  5.     VERSION:    0.0;
  6.     DATE:        06/15/1989;
  7.  
  8.     DESCRIPTION:    "This program lets you use your computer to assemble
  9.             code for the General Instruments PIC1650 family micro-
  10.             processors.  The program is written in portable C
  11.             rather than BDS C.  All assembler features are
  12.             supported except relocation, linkage, and macros.";
  13.  
  14.     KEYWORDS:    Software Development, Assemblers, Cross-Assemblers,
  15.             General Instruments, PIC1650;
  16.  
  17.     SYSTEM:        CP/M-80, CP/M-86, HP-UX, MSDOS, PCDOS, QNIX;
  18.     COMPILERS:    Aztec C86, Aztec CII, CI-C86, Eco-C, Eco-C88, HP-UX,
  19.             Lattice C, Microsoft C,    QNIX C;
  20.  
  21.     WARNINGS:    "This program has compiled successfully on 2 UNIX
  22.             compilers, 5 MSDOS compilers, and 2 CP/M compilers.
  23.             A port to BDS C would be extremely difficult.  A port
  24.             to Toolworks C is untried."
  25.  
  26.     AUTHORS:    William C. Colley III;
  27. */
  28.  
  29. /*
  30.              PIC1650 Cross-Assembler in Portable C
  31.  
  32.           Copyright (c) 1985,1987,1989 William C. Colley, III
  33.  
  34. Revision History:
  35.  
  36. Ver    Date        Description
  37.  
  38. 0.0    JUNE 1989    Derived from version 0.2 of my portable 8085 cross-
  39.             assembler.  WCC3.
  40.  
  41. This header file contains the global constants and data type definitions for
  42. all modules of the cross-assembler.  This also seems a good place to put the
  43. compilation and linkage instructions for the animal.  This list currently
  44. includes the following compilers:
  45.  
  46.         Compiler Name        Op. Sys.    Processor
  47.  
  48.     1)  Aztec C86            CP/M-86        8086, 8088
  49.                     MSDOS/PCDOS
  50.  
  51.     2)  AZTEC C II            CP/M-80        8080, Z-80
  52.  
  53.     3)  Computer Innovations C86    MSDOS/PCDOS    8086, 8088
  54.  
  55.     4)  Eco-C            CP/M-80        Z-80
  56.  
  57.     5)  Eco-C88            MSDOS/PCDOS    8086, 8088
  58.  
  59.     6)  HP C            HP-UX        68000
  60.  
  61.     7)  Lattice C            MSDOS/PCDOS    8086, 8088
  62.  
  63.     8)  Microsoft C            MSDOS/PCDOS    8086, 8088
  64.  
  65.     9)  QNIX C            QNIX        8086, 8088
  66.  
  67. Further additions will be made to the list as users feed the information to
  68. me.  This particularly applies to UNIX and IBM-PC compilers.
  69.  
  70. Compile-assemble-link instructions for this program under various compilers
  71. and operating systems:
  72.  
  73.     1)    Aztec C86:
  74.  
  75.     A)  Uncomment out the "#define AZTEC_C 1" line and comment out all
  76.         other compiler names in A16.H.
  77.  
  78.     B)  Assuming that all files are on drive A:, run the following sequence
  79.         of command lines:
  80.  
  81.         A>cc a16
  82.         A>cc a16eval
  83.         A>cc a16util
  84.         A>ln a16.o a16eval.o a16util.o -lc
  85.         A>era a16*.o
  86.  
  87.     2)  Aztec CII (version 1.06B):
  88.  
  89.     A)  Uncomment out the "#define AZTEC_C 1" line and comment out all
  90.         other compiler names in A16.H.
  91.  
  92.     B)  Assuming the C compiler is called "CC.COM" and all files are
  93.         on drive A:, run the following sequence of command lines:
  94.  
  95.         A>cc a16
  96.         A>as -zap a16
  97.         A>cc a16eval
  98.         A>as -zap a16eval
  99.         A>cc a16util
  100.         A>as -zap a16util
  101.         A>ln a16.o a16eval.o a16util.o -lc
  102.         A>era a16*.o
  103.  
  104.     3)  Computer Innovations C86:
  105.  
  106.     A)  Uncomment out the "#define CI_C86 1" line and comment out all
  107.         other compiler names in A16.H.
  108.  
  109.     B)  Compile the files A16.C, A16EVAL.C, and A16UTIL.C.  Link
  110.         according to instructions that come with the compiler.
  111.  
  112.     4)  Eco-C (CP/M-80 version 3.10):
  113.  
  114.     A)  Uncomment out the "#define ECO_C 1" line and comment out all
  115.         other compiler names in A16.H.
  116.  
  117.     B)  Assuming all files are on drive A:, run the following sequence of
  118.         command lines:
  119.  
  120.         A>cp a16 -i -m
  121.         A>cp a16eval -i -m
  122.         A>cp a16util -i -m
  123.         A>l80 a16,a16eval,a16util,a16/n/e
  124.         A>era a16*.mac
  125.         A>era a16*.rel
  126.  
  127.     5)  Eco-C88:
  128.  
  129.     A)  Uncomment out the "#define ECO_C 1" line and comment out all
  130.         other compiler names in A16.H.
  131.  
  132.     B)  Compile the files A16.C, A16EVAL.C, and A16UTIL.C.  Link
  133.         according to instructions that come with the compiler.
  134.  
  135.     6)  HP-UX (a UNIX look-alike running on an HP-9000 Series 200/500,
  136.     68000-based machine):
  137.  
  138.     A)  Uncomment out the "#define HP_UX 1" line and comment out all
  139.         other compiler names in A16.H.
  140.  
  141.     B)  Run the following command line:
  142.  
  143.         . cc a16.c a16eval.c a16util.c
  144.  
  145.     7)  Lattice C:
  146.  
  147.     A)  Uncomment out the "#define LATTICE_C 1" line and comment out all
  148.         other compiler names in A16.H.
  149.  
  150.     B)  Compile the files A16.C, A16EVAL.C, and A16UTIL.C.  Link
  151.         according to instructions that come with the compiler.
  152.  
  153.     8)  Microsoft C (version 3.00):
  154.  
  155.     A)  Uncomment out the "#define MICROSOFT_C 1" line and comment out
  156.         all other compiler names in A16.H.
  157.  
  158.     B)  Run the following command line:
  159.  
  160.         C>cl a16.c a16eval.c a16util.c
  161.  
  162.     9)    QNIX C:
  163.  
  164.     A)  Uncomment out the "#define QNIX 1" line and comment out all other
  165.         compiler names in A16.H.
  166.  
  167.     B)  Run the following command line:
  168.  
  169.         . cc a16.c a16eval.c a16util.c
  170.  
  171. Note that, under CP/M-80, you can't re-execute a core image from a previous
  172. assembly run with the "@.COM" trick.  This technique is incompatible with the
  173. Aztec CII compiler, so I didn't bother to support it at all.
  174. */
  175.  
  176. #include <stdio.h>
  177.  
  178. /*  Comment out all but the line containing the name of your compiler:    */
  179.  
  180. /* #define    AZTEC_C                            */
  181. /* #define    CI_C86                            */
  182. /* #define    ECO_C                            */
  183. /* #define    HP_UX                            */
  184. /* #define    LATTICE_C                        */
  185. #define        MICROSOFT_C
  186. /* #define    QNIX                            */
  187.  
  188. /*  Compiler dependencies:                        */
  189.  
  190. #ifdef    AZTEC_C
  191. #define    getc(f)        agetc(f)
  192. #define    putc(c,f)    aputc(c,f)
  193. #endif
  194.  
  195. #ifndef    ECO_C
  196. #define    FALSE        0
  197. #define    TRUE        (!0)
  198. #endif
  199.  
  200. #ifdef    LATTICE_C
  201. #define    void        int
  202. #endif
  203.  
  204. #ifdef    QNIX
  205. #define    fprintf        tfprintf
  206. #define    printf        tprintf
  207. #endif
  208.  
  209. /*  On 8-bit machines, the static type is as efficient as the register    */
  210. /*  type and far more efficient than the auto type.  On larger machines    */
  211. /*  such as the 8086 family, this is not necessarily the case.  To    */
  212. /*  let you experiment to see what generates the fastest, smallest code    */
  213. /*  for your machine, I have declared internal scratch variables in    */
  214. /*  functions "SCRATCH int", "SCRATCH unsigned", etc.  A SCRATCH    */
  215. /*  varible is made static below, but you might want to try register    */
  216. /*  instead.                                */
  217.  
  218. #define    SCRATCH        static
  219.  
  220. /*  A slow, but portable way of cracking an unsigned into its various    */
  221. /*  component parts:                            */
  222.  
  223. #define    clamp(u)    ((u) &= 0xffff)
  224. #define    high(u)        (((u) >> 8) & 0xff)
  225. #define    low(u)        ((u) & 0xff)
  226. #define    word(u)        ((u) & 0xffff)
  227.  
  228. /*  The longest source line the assembler can hold without exploding:    */
  229.  
  230. #define    MAXLINE        255
  231.  
  232. /*  The maximum number of source files that can be open simultaneously:    */
  233.  
  234. #define    FILES        4
  235.  
  236. /*  The fatal error messages generated by the assembler:        */
  237.  
  238. #define    ASMOPEN        "Source File Did Not Open"
  239. #define    ASMREAD        "Error Reading Source File"
  240. #define    DSKFULL        "Disk or Directory Full"
  241. #define    FLOFLOW        "File Stack Overflow"
  242. #define    HEXOPEN        "Object File Did Not Open"
  243. #define    IFOFLOW        "If Stack Overflow"
  244. #define    LSTOPEN        "Listing File Did Not Open"
  245. #define    NOASM        "No Source File Specified"
  246. #define    SYMBOLS        "Too Many Symbols"
  247.  
  248. /*  The warning messages generated by the assembler:            */
  249.  
  250. #define    BADOPT        "Illegal Option Ignored"
  251. #define    NOHEX        "-o Option Ignored -- No File Name"
  252. #define    NOLST        "-l Option Ignored -- No File Name"
  253. #define    TWOASM        "Extra Source File Ignored"
  254. #define    TWOHEX        "Extra Object File Ignored"
  255. #define    TWOLST        "Extra Listing File Ignored"
  256.  
  257. /*  Line assembler (A16.C) constants:                    */
  258.  
  259. #define    BIGINST        2        /*  longest instruction length    */
  260. #define    IFDEPTH        16        /*  maximum IF nesting level    */
  261. #define    NOP        0x000        /*  processor's NOP opcode    */
  262. #define    ON        1        /*  assembly turned on        */
  263. #define    OFF        -1        /*  assembly turned off        */
  264.  
  265. /*  Line assembler (A16.C) opcode attribute word flag masks:        */
  266.  
  267. #define    PSEUDO        0x100    /*  is pseudo op            */
  268. #define    ISIF        0x080    /*  is IF, ELSE, or ENDI        */
  269. #define    ARG2        0x060    /*  second argument descriptor        */
  270. #define    ARG1        0x01c    /*  first argument descriptor        */
  271. #define    NONE        0x000    /*    no argument            */
  272. #define    ADDR_9        0x004    /*    9-bit address            */
  273. #define    ADDR_8        0x008    /*    8-bit address            */
  274. #define    IMMED_8        0x00c    /*    8-bit immediate value        */
  275. #define    REG_5        0x010    /*    5-bit register number        */
  276. #define    TRIS_REG    0x014